import request from "@/utils/request";

/**
 * 获取用户信息
 *
 * return Promise
 */
export const getCurrentUserInfo = () => {
  return request({
    url: "/userInfo/getUserInfo",
    method: "GET",
  });
};


/**
 * 获取全部用户
 *
 * return Promise
 */
export const getAllUser = (data) => {
  return request({
    url: "/user/getAllUser",
    method: "POST",
    data
  })
}

/**
 * 获取用户的ip
 */
export const getUserIp = () => {
  return request({
    url: "/user/getUserIp",
    method: "GET"
  })
}

/**
 *  更新用户个人信息
 * @param {*} data promise
 * @returns
 */
export const updateUserInfo = (data) => {
  return request({
    url: "/userInfo/updateUserInfo",
    method: "POST",
    data,
  });
};

/**
 * 获取用户可以访问的页面
 * @returns 用户可以访问的页面集合
 */
export const getAccessPath = () => {
  return request({
    url: "/role/getAccessPath",
    method: "GET",
  });
};

/**
 * 判断电话号码是否可用
 */
export const checkPhone = (data) => {
  return request({
    url: "/userInfo/checkPhone",
    method: "GET",
    params: data,
  });
};

/**
 * 向电话号码发送信息
 */
export const sendMsg = (data) => {
  return request({
    url: "/user/sendMsg",
    method: "POST",
    params: data,
  });
};

/**
 * 通过ID获取指定的用户信息
 * @param {*} id
 * @returns
 */
export const getUserInfoById = (id) => {
  return request({
    url: `/userInfo/getUserInfoById/${id}`,
    method: "GET",
  });
};

/**
 * 新增用户
 * @param {*} data
 */
export const addUser = (data) => {
  return request({
    url: "/user/admin/addUser",
    method: "POST",
    data: data,
  });
};


/**
 * 根据用户ID删除用户
 * @param {*} id
 * @returns
 */
export const deleteUserById = (id) => {
  return request({
    url: `/user/admin/deleteUserById/${id}`,
    method: "DELETE",
  });
};
